<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<ui:composition template="/HomeTemplate.xhtml"
                xmlns="http://www.w3.org/1999/xhtml"
                xmlns:f="http://java.sun.com/jsf/core"
                xmlns:h="http://java.sun.com/jsf/html"
                xmlns:ui="http://java.sun.com/jsf/facelets"
                xmlns:p="http://primefaces.org/ui"
                >
    <ui:define name="body">

        <h:form> 

            <p:dataTable id="dataTable" var="dealer" value="#{loginBean.dealersByUser}" widgetVar="dealerTable" paginator="true"
                         paginatorTemplate="{CurrentPageReport}  {FirstPageLink} {PreviousPageLink} {PageLinks}
                         {NextPageLink} {LastPageLink} {RowsPerPageDropdown}" paginatorPosition="bottom"
                         rows="7" rowsPerPageTemplate="7,14,21"
                         >  
                <p:column >  
                    <f:facet name="header">  
                        User Name
                    </f:facet>  

                    <h:outputText value="#{dealer.userName}" />  

                </p:column>  

                <p:column >  
                    <f:facet name="header">  
                        ID No / VAT No
                    </f:facet>  

                    <h:outputText value="#{dealer.numDoc}" />  

                </p:column>  
                <p:column >  
                    <f:facet name="header">  
                        Email
                    </f:facet>  

                    <h:outputText value="#{dealer.email}" />  

                </p:column>  

                <f:facet name="footer">  
                    In total there are #{loginBean.dealersByUser.size()} Items.  
                </f:facet>  

            </p:dataTable> 


            <h:panelGrid id="buttons" columns="5" cellpadding="4" style="border-bottom-width: 30px">  
                <p:commandButton  value="Add" onclick="panelwv.show();"  type="button" > </p:commandButton>   
            </h:panelGrid>

            <p:panel id="editPanel" header="Create Dealer User" widgetVar="panelwv" visible="false" style="width: 700px;">  

                <h:panelGrid id="editGrid" columns="4">  

                    <h:outputText value="User Name: *" />   
                    <p:inputText id="nam" value="#{loginBean.userDealer.userName}" required="true" label="Username"/>  


                    <h:outputText value="Password: *" />   
                    <p:password id="desc" value="#{loginBean.userDealer.password}" required="true" label="Password"/> 


                    <h:outputText value="Email *" />   
                    <p:inputText id="email" value="#{loginBean.userDealer.email}" required="true" label="Email"/> 


                    <h:outputText value="VAT No " />   
                    <p:inputText id="vat" value="#{loginBean.userDealer.numDoc}" label="Vat"/> 

                </h:panelGrid>  
                <p:message id="textOnlyMessage" for="nam" display="text" /> 
                <p:message id="textOnlyMessage2" for="desc" display="text" />
                <p:message id="textOnlyMessage3" for="email" display="text" />
                <p:commandButton value="Save" actionListener="#{loginBean.createUserDealer()}" update="dataTable, textOnlyMessage, textOnlyMessage2, textOnlyMessage3" oncomplete="panelwv.hide();"/>

                <p:commandButton value="Cancel" ajax="true" onclick="panelwv.hide();" immediate="true">

                </p:commandButton> 

            </p:panel>  

        </h:form>  


    </ui:define>
</ui:composition>